package com.zxy.supplier_system.server.entity

import jakarta.persistence.*
import org.hibernate.annotations.DynamicInsert
import org.hibernate.annotations.DynamicUpdate
import java.io.Serializable

@Entity
@IdClass(MarketCheckInventoryRecordItem.UnionId::class)
@DynamicUpdate
@DynamicInsert
class MarketCheckInventoryRecordItem {

    data class UnionId(
        var goods:Int = 0,
        var record:Int = 0,
        var subGoods:Int? = null,
    ):Serializable

    @ManyToOne(optional = false)
    @JoinColumn
    @Id
    lateinit var goods: Goods

    @ManyToOne
    @JoinColumn(nullable = true)
    @Id
    var subGoods: SubGoods? = null

    @Column(nullable = false)
    var amount: Int = 0

    @ManyToOne(optional = false, fetch = FetchType.LAZY, cascade = [])
    @JoinColumn(nullable = false)
    @Id
    lateinit var record: MarketCheckInventoryRecord

    var sequence: Int = 0

}
